stylepropertis: Use set_by_property() in set_valist()
authorBenjamin Otte <otte@redhat.com>
Sat, 21 May 2011 19:19:57 +0000 (21:19 +0200)
committerBenjamin Otte <otte@redhat.com>
Sat, 21 May 2011 23:25:16 +0000 (01:25 +0200)
... instead of duplicating code. This causes an extra g_value_copy().
If that turns out to be a performance issue, we can invent something
that handles this (like passing a gboolean take_value).

The reason for this duplication deletion is that we want to complicate
the setting code to handle shorthands by unpacking them and storing the
separate values.

gtk/gtkstyleproperties.c

index 946347f7951e5979336f2dcd9846ca5e8468bbea..1c5f0d95651a14d8e169a280b819447463f3ea0d 100644 (file)
@@ -600,9 +600,8 @@ gtk_style_properties_set_valist (GtkStyleProperties *props,
   while (property_name)
     {
       const GtkStyleProperty *node;
-      PropertyData *prop;
       gchar *error = NULL;
-      GValue *val;
+      GValue val;
 
       node = _gtk_style_property_lookup (property_name);
 
@@ -612,30 +611,19 @@ gtk_style_properties_set_valist (GtkStyleProperties *props,
           break;
         }
 
-      prop = g_hash_table_lookup (priv->properties, node->pspec);
-
-      if (!prop)
-        {
-          prop = property_data_new ();
-          g_hash_table_insert (priv->properties, node->pspec, prop);
-        }
-
-      val = property_data_get_value (prop, state);
-
-      if (G_IS_VALUE (val))
-        g_value_unset (val);
-
-      G_VALUE_COLLECT_INIT (val, node->pspec->value_type,
+      G_VALUE_COLLECT_INIT (&val, node->pspec->value_type,
                             args, 0, &error);
-      g_param_value_validate (node->pspec, val);
       if (error)
         {
           g_warning ("Could not set style property \"%s\": %s", property_name, error);
-          g_value_unset (val);
+          g_value_unset (&val);
           g_free (error);
           break;
         }
 
+      _gtk_style_properties_set_property_by_property (props, node, state, &val);
+      g_value_unset (&val);
+
       property_name = va_arg (args, const gchar *);
     }
 }